import { IPSModelSortable } from '../../ipsmodel-sortable';
import { IPSDEMSLogic } from './ipsdemslogic';
import { IPSDEMSLogicNode } from './ipsdemslogic-node';
import { IPSDEMSLogicParam } from './ipsdemslogic-param';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMSLogicImpl extends PSModelObjectImpl implements IPSDEMSLogic, IPSModelSortable {
  get codeName(): string {
    return this.M.codeName;
  }

  get defaultParamName(): string {
    return this.M.defaultParamName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psdemslogicnodes: IPSDEMSLogicNode[] | null = null;

  getPSDEMSLogicNodes(): IPSDEMSLogicNode[] | null {
    if (this.psdemslogicnodes == null) {
      this.psdemslogicnodes = this.fillChildListModel(this.M.getPSDEMSLogicNodes, 'dataentity.logic.IPSDEMSLogicNode') as IPSDEMSLogicNode[];
    }
    return this.psdemslogicnodes;
  }

  get psDEMSLogicNodes(): IPSDEMSLogicNode[] | null {
    return this.getPSDEMSLogicNodes();
  }

  findPSDEMSLogicNode(objKey: any): IPSDEMSLogicNode | null {
    return this.getPSModel5('dataentity.logic.IPSDEMSLogicNode', this.getPSDEMSLogicNodes(), objKey) as IPSDEMSLogicNode;
  }

  protected psdemslogicparams: IPSDEMSLogicParam[] | null = null;

  getPSDEMSLogicParams(): IPSDEMSLogicParam[] | null {
    if (this.psdemslogicparams == null) {
      this.psdemslogicparams = this.fillChildListModel(this.M.getPSDEMSLogicParams, 'dataentity.logic.IPSDEMSLogicParam') as IPSDEMSLogicParam[];
    }
    return this.psdemslogicparams;
  }

  get psDEMSLogicParams(): IPSDEMSLogicParam[] | null {
    return this.getPSDEMSLogicParams();
  }

  findPSDEMSLogicParam(objKey: any): IPSDEMSLogicParam | null {
    return this.getPSModel5('dataentity.logic.IPSDEMSLogicParam', this.getPSDEMSLogicParams(), objKey) as IPSDEMSLogicParam;
  }

  protected startpsdemslogicnode: IPSDEMSLogicNode | null = null;

  getStartPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    if (this.startpsdemslogicnode != null) return this.startpsdemslogicnode;
    const value = this.M.getStartPSDEMSLogicNode;
    if (value == null) {
      return null;
    }
    this.startpsdemslogicnode = this.findPSDEMSLogicNode(value);
    return this.startpsdemslogicnode;
  }

  get startPSDEMSLogicNode(): IPSDEMSLogicNode | null {
    return this.getStartPSDEMSLogicNode();
  }

  getStartPSDEMSLogicNodeMust(): IPSDEMSLogicNode {
    const value = this.getStartPSDEMSLogicNode();
    if (value == null) {
      throw new Error('未指定开始处理节点');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode;
  }

  get cls(): string {
    return 'PSDEMSLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'dataentity.logic.IPSDEMSLogic') return true;
    return super.instanceof(cls);
  }
}
